{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5d017f68-eec1-47ce-a86b-5e7c6a6056e7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      " 天秤座\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "天秤座♎的生日位于9月23-10月23之间\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      " 我的\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入星座名称有误！\n"
     ]
    }
   ],
   "source": [
    "#读入CSV格式数据到列表中\n",
    "fo = open(\"SunSign.csv\",\"r\", encoding='utf-8')\n",
    "ls = []\n",
    "for line in fo:\n",
    "    line = line.replace(\"\\n\",\"\")\n",
    "    ls.append(line.split(\",\"))\n",
    "fo.close()\n",
    "while True:\n",
    "    InputStr = input() # 请输入星座名称,例如双子座\n",
    "    InputStr.strip()\n",
    "    flag = False\n",
    "    if InputStr == 'exit':\n",
    "        break\n",
    "    for line in ls:\n",
    "        if InputStr == line[0]:\n",
    "            print(\"{}{}的生日位于{}-{}之间\".format(line[0],chr(int(line[3])),line[1],line[2]))\n",
    "            flag = True\n",
    "    if flag == False:\n",
    "        print(\"输入星座名称有误！\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38abcad6-506d-444c-a09e-c48fdcc1e3f0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
